package com.java.hibernate.dao;

import org.hibernate.Session;
import org.springframework.data.repository.NoRepositoryBean;
import org.springframework.stereotype.Repository;

import java.io.Serializable;
import java.util.List;

/**
 * @Author: Dgg
 * @Date: 2022/4/22 21:35
 */
public interface SpringBootHibernateCommonDao<T> {
	/**
	 * 保存
	 */
	public abstract Serializable save(T entity);

	/**
	 * 更新
	 */
	public abstract void update(T entity);

	/**
	 * 删除
	 */
	public abstract void delete(T entity);

	/**
	 * 保存更新
	 */
	public abstract void saveOrUpdate(T entity);

	/**
	 * 获取
	 */
	public abstract T loadById(final Serializable id);

	/**
	 * 根据属性获取list
	 */
	public List<T> loadListByProperty(String name, Object val, String sort);

	/**
	 * 根据属性获取list
	 */
	public List<T> loadListByProperty(String name, Object val);

	/**
	 * 根据属性获取对象
	 */
	public T loadUniqueByProperty(String name, Object val);

	void refreshSessionObject(T t);

	public Session getSession();

	public void clearTemplate();
}
